﻿using GLstudent.DAL;
using GLstudent.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GLstudent.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class guanliyuanController : ControllerBase
    {
        DAL_guanliyuan guanli = new DAL_guanliyuan();
        /// <summary>
        /// 查询班级表所有信息的方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
       public List<banji> chaxun()
        {
            return guanli.Select();
        }
        /// <summary>
        /// 按ID查询班级信息的方法
        /// </summary>
        /// <param name="banjiid">班级的id</param>
        /// <returns></returns>
        [HttpGet]
        public chakanbanji chaxunid(int banjiid)
        {
            return guanli.chaxunid(banjiid);
        }
        /// <summary>
        /// 模糊查询班级
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <returns></returns>
        [HttpGet]
        public List<banji> mohuchanxun(string mohu)
        {
            return guanli.mohu(mohu);
        }
        /// <summary>
        /// 新增班级的方法
        /// </summary>
        /// <param name="zengjia">对应banji的类</param>
        /// <returns></returns>
        [HttpPost]
        public int xinzeng(banji zengjia)
        {
            return guanli.Insert(zengjia);
        }
        /// <summary>
        /// 删除班级的方法
        /// </summary>
        /// <param name="id">要删除的班级的id</param>
        /// <returns></returns>
        [HttpGet]
        public int shanchu(int id)
        {
            return guanli.Delete(id);
        }
        /// <summary>
        /// 修改班级的方法
        /// </summary>
        /// <param name="g">与banji的类对应</param>
        /// <returns></returns>
        [HttpPost]
        public int xiugai(banji g)
        {
            return guanli.Update(g);
        }
        /// <summary>
        /// 查询课程表所有信息的方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<kecheng> chaxunkecheng()
        {
            return guanli.Selectkecheng();
        }
        /// <summary>
        /// 模糊查询课程
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <returns></returns>
        [HttpGet]   
        public List<kecheng> mohukecheng(string mohu)
        {
            return guanli.mohukecheng(mohu);
        }
        /// <summary>
        /// 按ID查询课程信息的方法
        /// </summary>
        /// <param name="kechengid">课程的id</param>
        /// <returns></returns>
        [HttpGet]
        public chakankecheng kechengid(int kechengid)
        {
            return guanli.chaxunkechengid(kechengid);
        }
        /// <summary>
        /// 新增课程的方法
        /// </summary>
        /// <param name="zengjia">与kecheng类对应的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xinzengkecheng(kecheng zengjia)
        {
            return guanli.Insertkecheng(zengjia);
        }
        /// <summary>
        /// 删除课程的方法
        /// </summary>
        /// <param name="id">要删除的课程的id</param>
        /// <returns></returns>
        [HttpGet]
        public int shanchukecheng(int id)
        {
            return guanli.Deletekecheng(id);
        }
        /// <summary>
        /// 修改课程的方法
        /// </summary>
        /// <param name="g">与kecheng对应的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xiugaikecheng(kecheng g)
        {
            return guanli.Updatekecheng(g);
        }
        /// <summary>
        ///查询教师表所有信息的方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<teacher> chaxunjiaoshi()
        {
            return guanli.Selectjiaoshi();
        }
        /// <summary>
        ///模糊查询教师
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <returns></returns>
        [HttpGet]
        public List<teacher> mohujiaoshi(string mohu)
        {
            return guanli.mohujiaoshi(mohu);
        }
        /// <summary>
        /// 按ID查询教师信息的方法
        /// </summary>
        /// <param name="id">要查询的教师id</param>
        /// <returns></returns>
        [HttpGet]
        public teacher teacherid(int id)
        {
            return guanli.chaxunjiaoshiid(id);
        }
        /// <summary>
        /// 新增教师的方法
        /// </summary>
        /// <param name="zengjia">对应teacher的类的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xinzengjiaoshi(teacher zengjia)
        {
            return guanli.Insertjiaoshi(zengjia);
        }
        /// <summary>
        /// 删除教师的方法
        /// </summary>
        /// <param name="id">要删除的教师的id</param>
        /// <returns></returns>
        [HttpGet]
        public int shanchujiaoshi(int id)
        {
            return guanli.Deletejiaoshi(id);
        }
        /// <summary>
        /// 修改教师的方法
        /// </summary>
        /// <param name="g">与teacher对应类的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xiugaijiaoshi(teacher g)
        {
            return guanli.Updatejiaoshi(g);
        }
        /// <summary>
        /// 查询登录表所有信息的方法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<denglu> chaxundenglu()
        {
            return guanli.Selectdenglu();
        }
        /// <summary>
        /// 模糊查询登录表
        /// </summary>
        /// <param name="mohu">模糊查询输入的字符</param>
        /// <returns></returns>
        [HttpGet]
        public List<denglu> mohudenglu(string mohu)
        {
            return guanli.mohudenglu(mohu);
        }
        /// <summary>
        /// 按教师编号查询教师信息的方法
        /// </summary>
        /// <param name="jiaoshibianhao">要查询的教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public denglubiaojiaoshishitu chaxunjiaoshibianhao(string jiaoshibianhao)
        {
            return guanli.chaxunbianhao(jiaoshibianhao);
        }
        /// <summary>
        /// 按学生学号查询学生信息的方法
        /// </summary>
        /// <param name="xueshengxuehao">要查询的学生学号</param>
        /// <returns></returns>
        [HttpGet]
        public denglubiaoxuesheng chaxunxuesheng(string xueshengxuehao)
        {
            return guanli.chaxunxuehao(xueshengxuehao);
        }
        /// <summary>
        /// 删除登录信息的方法
        /// </summary>
        /// <param name="id">要删除的登录信息id</param>
        /// <returns></returns>
        [HttpGet]
        public int shanchudenglu(int id)
        {
            return guanli.Deletedenglu(id);
        }
        /// <summary>
        /// 修改登录信息的方法
        /// </summary>
        /// <param name="g">与denglu类对应的参数</param>
        /// <returns></returns>
        [HttpPost]
        public int xiugaidenglu(denglu g)
        {
            return guanli.Updatedenglu(g);
        }
        /// <summary>
        /// 查询所有学生信息并按照班级名称排序
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<student> chaxunsuoyou()
        {
            return guanli.chaxunsuoyou();
        }
        /// <summary>
        /// 模糊查询学生表信息
        /// </summary>
        /// <param name="mohu">模糊查询的字符</param>
        /// <returns></returns>
        [HttpGet]
        public List<student> mohuxuesheng(string mohu)
        {
            return guanli.mohuxuesheng(mohu);
        }
        /// <summary>
        /// 查询学生表内是否有该班的学生
        /// </summary>
        /// <param name="bname">班级名称</param>
        /// <returns></returns>
        [HttpGet]
        public List<student> chaxunbanjixuesheng(string bname)
        {
            return guanli.chaxunbanjixuesheng(bname);
        }
        /// <summary>
        /// 查询教师是否是班主任
        /// </summary>
        /// <param name="tbianhao">教师编号</param>
        /// <returns></returns>
        [HttpGet]
        public List<banji> chaxunbanzhuren(string tbianhao)
        {
            return guanli.chaxunbanzhuren(tbianhao);
        }
        /// <summary>
        /// 查询班级表中是否有该班级
        /// </summary>
        /// <param name="bname">班级名称</param>
        /// <returns></returns>
        [HttpGet]
        public List<banji> chaxunbanji(string bname)
        {
            return guanli.chaxunbanji(bname);
        }
        /// <summary>
        /// 查询该科目下是否有学生学习
        /// </summary>
        /// <param name="kname">课程名称</param>
        /// <returns></returns>
        [HttpGet]
        public List<chaxunkemu> chaxunkemu(string kname)
        {
            return guanli.chaxunkemu(kname);
        }
    }
}
